import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import Login from '@/components/Login'
import NotFound from '@/components/NotFound'
import Index from '@/components/home/index'
import OwnerAdd from '@/components/owner/OwnerAdd'
import OwnerAddUser from '@/components/owner/OwnerAddUser'
import OwnerList from '@/components/owner/OwnerList'
import test from '@/components/test'

/**宠物信息*/
import PetInfoList from '@/components/petInfo/PetInfoList'
import PetTypeInfoList from '@/components/petTypeInfo/PetTypeInfoList'

/**医疗记录管理*/
import MedicalTreatmentList from '@/components/medicalTreatment/MedicalTreatmentList'

/**咨询信息管理*/
import ArticleInformationList from '@/components/articleInformation/ArticleInformationList'

/**用户评价反馈管理*/
import TbRecommendationList from '@/components/tbRecommendation/tbRecommendationList'

/**用户主页*/
import UserIndex from '@/components/user/index'
import ContentDts from '@/components/user/contentDts'
import UerDefault from '@/components/user/userDefault'
import CenterUser from '@/components/user/centerUser'
import More from '@/components/user/more'
import MoreQuery from '@/components/user/moreQuery'


const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

let head = document.getElementsByTagName('head')
let meta = document.createElement('meta')
meta.name = 'referrer'
// 根据实际情况修改referrer的值，可选值参考上文
meta.content = 'no-referrer'
head[0].appendChild(meta)

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: 'login',
      hidden: true
    },
    {
      path: '/login',
      name: 'login',
      component: Login,
      hidden: true
    },
    {
      props: true,
      path: '/userHome/:index',
      name: '用户首页',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/userHome/contentDts/:name',
          name: '首页详细',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/userHome/default/:id',
          name: '首页数据',
          component: UerDefault,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/userHome/register',
          name: '用户注册',
          component: OwnerAddUser,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '/article',
      name: '文章',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/article/contentDts/:name',
          name: '文章详细',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/article/default/:id',
          name: '文章数据',
          component: UerDefault,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '/info',
      name: '资讯',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/info/contentDts/:name',
          name: '文章详细',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/info/default/:id',
          name: '文章数据',
          component: UerDefault,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '/video',
      name: '视频',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/video/contentDts/:name',
          name: '视频详细',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/video/default/:id',
          name: '视频数据',
          component: UerDefault,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '/more',
      name: '更多',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/more/moreQuery/:name',
          name: '99999',
          component: MoreQuery,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/more/more/:id/:type',
          name: '99999',
          component: More,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/more/feeding/contentDts/:name',
          name: '饲养',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/more/medicalTreatment/contentDts/:name',
          name: '医疗',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
        {
          props: true,
          path: '/more/train/contentDts/:name',
          name: '训练',
          component: ContentDts,
          iconClass: 'fa fa-users'
        },
      ]
    },
    {
      path: '/center',
      name: '个人中心',
      component: UserIndex,
      hidden: true,
      children: [
        {
          props: true,
          path: '/center/home',
          name: '99999',
          component: CenterUser,
          iconClass: 'fa fa-users',
          children: [{
            props: true,
            path: '/center/home/petInfo',
            name: '宠物信息',
            component: PetInfoList,
            iconClass: 'fa fa-users',
          },{
            props: true,
            path: '/center/home/medicalTreatmentList',
            name: '医疗信息',
            component: MedicalTreatmentList,
            iconClass: 'fa fa-users',
          },{
            props: true,
            path: '/center/home/tbRecommendationList',
            name: '用户评价反馈',
            component: TbRecommendationList,
            iconClass: 'fa fa-users',
          },{
            props: true,
            path: '/center/home/ownerList',
            name: '个人中心',
            component: OwnerList,
            iconClass: 'fa fa-users',
          }]
        }
      ]
    },
    {
      path: '/test',
      name: 'test',
      component: test,
      hidden: true
    },
    {
      path: '/home',
      name: '首页',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/index',
          name: '统计报表',
          component: Index,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '/owner',
      name: '用户信息管理',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/OwnerAdd',
          name: '用户信息填报',
          component: OwnerAdd,
          iconClass: 'fa fa-users'
        },
        {
          path: '/home/OwnerList',
          name: '用户信息列表',
          component: OwnerList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '/petInfo',
      name: '宠物信息管理',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/PetTypeInfoList',
          name: '宠物类型列表',
          component: PetTypeInfoList,
          iconClass: 'fa fa-list'
        }, {
          path: '/home/PetInfoList',
          name: '宠物信息列表',
          component: PetInfoList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '/medicalTreatment',
      name: '医疗记录信息管理',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/MedicalTreatmentList',
          name: '医疗记录列表',
          component: MedicalTreatmentList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '/articleInformation',
      name: '文章资讯信息管理',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/ArticleInformationList',
          name: '文章资讯列表',
          component: ArticleInformationList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '/tbRecommendationList',
      name: '用户评价反馈',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/TbRecommendationList',
          name: '文章咨询列表',
          component: TbRecommendationList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '*',
      name: 'NotFound',
      component: NotFound,
      hidden: true
    }
  ],
  routesUser: [
    {
      path: '/',
      redirect: 'test',
      hidden: true
    },
    {
      path: '/login',
      name: 'login',
      component: Login,
      hidden: true
    },
    {
      path: '/owner',
      name: '居民信息管理',
      component: Home,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/OwnerAdd',
          name: '居民信息填报',
          component: OwnerAdd,
          iconClass: 'fa fa-users'
        },
        {
          path: '/home/OwnerList',
          name: '居民信息列表',
          component: OwnerList,
          iconClass: 'fa fa-list'
        }
      ]
    },
    {
      path: '/home',
      name: '首页',
      component: Home,
      hidden: true,
      iconClass: 'fa fa-list-alt',
      children: [
        {
          path: '/home/index',
          name: '首页',
          component: Index,
          iconClass: 'fa fa-users'
        }
      ]
    },
    {
      path: '*',
      name: 'NotFound',
      component: NotFound,
      hidden: true
    }
  ],
  mode:
    'history'
})
